package com.example.adapter;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.base.MeBaseAdapter;
import com.example.bean.News;
import com.example.rzprogram.R;
import com.lidroid.xutils.BitmapUtils;

public class HomeAdapter extends MeBaseAdapter<News> {
	public HomeAdapter(List<News> list, Context context) {
		super(list, context);
	}

	@Override
	public View createView(int position, View convetView, ViewGroup parent) {
		ViewHolder viewHolder = null;
		if (convetView==null) {
			convetView =inflater.inflate(R.layout.home_listitem,null);
			viewHolder = new ViewHolder();
			viewHolder.tv_tilte = (TextView) convetView.findViewById(R.id.home_list_title);
			viewHolder.image = (ImageView) convetView.findViewById(R.id.home_list_image);
			convetView.setTag(viewHolder);
		}else {
			viewHolder = (ViewHolder) convetView.getTag();
		}
		viewHolder.tv_tilte.setText(list.get(position).getNewsTitle());
		
		BitmapUtils bitmapUtils = new BitmapUtils(context);
		bitmapUtils.display(viewHolder.image, "http://123.57.206.91/"+list.get(position).getImagePath());
		return convetView;
	}
    public static class ViewHolder{
    	ImageView image;
    	TextView tv_tilte;
    }
}
